from rest_framework.viewsets import ModelViewSet
from manage.authentication import JWTAuth
from manage.models.system import Role
from manage.permission import CustomPermission
from manage.serializers.system import RoleSerializer
# 角色管理
class RoleViewSet(ModelViewSet):
    queryset = Role.objects.all()
    serializer_class = RoleSerializer
    # 使用自定义登录认证类验证登录状态
    authentication_classes = (JWTAuth,)
    # 使用自定义权限验证类进行权限验证
    permission_classes = [CustomPermission]
    # 设置权限代码
    rbac_permissions={
        'list': 'role:list',
        'retrieve': 'role:detail',
        'create': 'role:create',
        'update': 'role:update',
        'partial_update': 'role:update',
        'destroy': 'role.destroy'
    }